package com.myutil.draw;

import java.awt.Graphics;
import javax.swing.JPanel;
import com.myutil.graph.CorNode;

public class Map extends JPanel{
	
	private static final long serialVersionUID = 1L;
	public Nodedrawable[] nodes;
	public Edgedrawable[] edges;
	
	public Map(Nodedrawable[] nodes, Edgedrawable[] edges) {
		this.nodes = nodes;
		this.edges = edges;
	}

//	@Override
//	public void paint(Graphics g) {
//		for(Nodedrawable draw : nodes){
//			g.setColor(draw.color);
//			CorNode node=draw.node;
//			g.fillOval(node.x,node.y,5,5);
//		}
//		for(Edgedrawable draw:edges){
//			g.setColor(draw.color);
//			CorEdge edge=draw.edge;
//			g.drawLine(edge.start.x, edge.start.y, edge.end.x, edge.end.y);
//		}
//	}
	
	@Override
	protected void paintComponent(Graphics g) {
		for(Nodedrawable draw : nodes){
			g.setColor(draw.color);
			CorNode node=draw.node;
			g.fillOval(node.x,node.y,10,10);
		}
		for(Edgedrawable draw:edges){
			g.setColor(draw.color);
			CorNode x1=draw.edge.start;
			CorNode x2=draw.edge.end;
			g.drawLine(x1.x+5, x1.y+5, x2.x+5, x2.y+5);
		}
	}

}
